/*
 * ILockManager.java
 * Created on 2006-12-5
 *
 * @Description: com.bearingpoint.hr.payroll.piinterface.domain.support
 */
package com.mycompany.app.hr.common.mutexlock;

/**
 * @author martin.liu
 * @version: 0.9, 2006-12-5
 *
 * @Description: ILockManager
 * Provide lock mechanism to, 
 * 1.Gurantee one task running exclusively
 * 2.Make sure some resources can be accessed exclusively.
 * 
 * TODO list
 * 1.manage a group of taks or resources
 * 2.provide more acquiry mode, fail to acquire, wait given time or wait infinite.
 * 3.Extract a interface for token to support contracts such as querying lock applicant, 
 * or comparing lock applicant. 
 * 
 */
public interface IMutexLockManager {

	/**
	 * Enquery whether one task or resource is locked or not.
	 * @Description:
	 * @return
	 */
	boolean isLock(Object token);
	
	
	/**
	 * Lock one task or resource.
	 * If fail to acquire the lock, system will raise FailedAcquireLockException exception.
	 * @Description:
	 * @param token
	 * @exception FailedAcquireLockException
	 */
	void acquireLock(Object token) throws FailedAcquireLockException;
	
	
	/**
	 * Lock one task or resource.
	 * @Description:
	 * @param token
	 */
	void releaseLock(Object token);
	
}